/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * InventoryManager.java
 *
 * Created on Aug 28, 2010, 11:19:03 AM
 */
package GUI;

import BusinessLogic.*;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Vector;
import javax.swing.JOptionPane;
import javax.swing.table.TableModel;

/**
 *
 * @author MrToan
 */
public class InventoryManager extends javax.swing.JPanel {

    /** Creates new form InventoryManager */
    private User user;

    public InventoryManager(User userObj) {
        user = userObj;
        initComponents();
        txtName.setText(user.getName());
        txtPhone.setText(user.getPhone());
        txtEmail.setText(user.getEmail());
        txtAddress.setText(user.getAddress());
        txtUserName.setText(user.getUserName());
        txtRoles.setText(user.getRole());
        txtPer.setText(Integer.toString(user.getPermiss()));
        GenerateInfo();
    }

   InventoryManagementFunction_BL function_BL=new InventoryManagementFunction_BL();
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel1 = new javax.swing.JPanel();
        pn_MangerInfo1 = new javax.swing.JPanel();
        lb_username1 = new javax.swing.JLabel();
        lb_Roles1 = new javax.swing.JLabel();
        lb_permis1 = new javax.swing.JLabel();
        txtUserName = new javax.swing.JTextField();
        txtRoles = new javax.swing.JTextField();
        txtPer = new javax.swing.JTextField();
        bntChangePass1 = new javax.swing.JButton();
        pn_PersonInfo3 = new javax.swing.JPanel();
        lb_Address3 = new javax.swing.JLabel();
        lb_phone3 = new javax.swing.JLabel();
        lb_Email3 = new javax.swing.JLabel();
        txtPhone = new javax.swing.JTextField();
        txtEmail = new javax.swing.JTextField();
        jScrollPane4 = new javax.swing.JScrollPane();
        txtAddress = new javax.swing.JTextArea();
        bnt_Change3 = new javax.swing.JButton();
        jLabel11 = new javax.swing.JLabel();
        txtName = new javax.swing.JTextField();
        jPanel2 = new javax.swing.JPanel();
        jPanel7 = new javax.swing.JPanel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        txtNotAvailable = new javax.swing.JTextField();
        txtItemSold = new javax.swing.JTextField();
        bntViewItemNotAvailable = new javax.swing.JButton();
        bntViewItemSold = new javax.swing.JButton();
        jLabel10 = new javax.swing.JLabel();
        txtTotalMoney = new javax.swing.JTextField();
        jPanel8 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        tbItem1 = new javax.swing.JTable();
        jPanel4 = new javax.swing.JPanel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        txtNow = new javax.swing.JTextField();
        jPanel6 = new javax.swing.JPanel();
        jScrollPane3 = new javax.swing.JScrollPane();
        tbItem2 = new javax.swing.JTable();
        cbCate = new javax.swing.JComboBox();
        jLabel7 = new javax.swing.JLabel();
        cbLastMonth = new javax.swing.JComboBox();
        jPanel3 = new javax.swing.JPanel();
        InventoryStatus = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        txtTotalCate = new javax.swing.JTextField();
        txtTotalItem = new javax.swing.JTextField();
        txtUpdateQuantity = new javax.swing.JTextField();
        bntUpdate = new javax.swing.JButton();
        jPanel5 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        tbItem = new javax.swing.JTable();

        pn_MangerInfo1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Management Information", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 18))); // NOI18N

        lb_username1.setText("UserName :");

        lb_Roles1.setText("Roles :");

        lb_permis1.setText("Permisson :");

        txtUserName.setEditable(false);

        txtRoles.setEditable(false);

        txtPer.setEditable(false);

        bntChangePass1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/Edit-icon.png"))); // NOI18N
        bntChangePass1.setText("Change Password");
        bntChangePass1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bntChangePass1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pn_MangerInfo1Layout = new javax.swing.GroupLayout(pn_MangerInfo1);
        pn_MangerInfo1.setLayout(pn_MangerInfo1Layout);
        pn_MangerInfo1Layout.setHorizontalGroup(
            pn_MangerInfo1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pn_MangerInfo1Layout.createSequentialGroup()
                .addGroup(pn_MangerInfo1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pn_MangerInfo1Layout.createSequentialGroup()
                        .addGap(30, 30, 30)
                        .addGroup(pn_MangerInfo1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lb_username1)
                            .addComponent(lb_Roles1)
                            .addComponent(lb_permis1))
                        .addGap(49, 49, 49)
                        .addGroup(pn_MangerInfo1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(txtUserName, javax.swing.GroupLayout.DEFAULT_SIZE, 155, Short.MAX_VALUE)
                            .addComponent(txtRoles)
                            .addComponent(txtPer)))
                    .addGroup(pn_MangerInfo1Layout.createSequentialGroup()
                        .addGap(58, 58, 58)
                        .addComponent(bntChangePass1, javax.swing.GroupLayout.PREFERRED_SIZE, 174, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(14, Short.MAX_VALUE))
        );
        pn_MangerInfo1Layout.setVerticalGroup(
            pn_MangerInfo1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pn_MangerInfo1Layout.createSequentialGroup()
                .addGap(28, 28, 28)
                .addGroup(pn_MangerInfo1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lb_username1)
                    .addComponent(txtUserName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(37, 37, 37)
                .addGroup(pn_MangerInfo1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lb_Roles1)
                    .addComponent(txtRoles, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(42, 42, 42)
                .addGroup(pn_MangerInfo1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(lb_permis1)
                    .addComponent(txtPer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 165, Short.MAX_VALUE)
                .addComponent(bntChangePass1))
        );

        pn_PersonInfo3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Personal Information", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 18))); // NOI18N

        lb_Address3.setText("Address :");

        lb_phone3.setText("Phone :");

        lb_Email3.setText("Email :");

        txtAddress.setColumns(20);
        txtAddress.setRows(5);
        jScrollPane4.setViewportView(txtAddress);

        bnt_Change3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/Edit-icon.png"))); // NOI18N
        bnt_Change3.setText("Update");
        bnt_Change3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bnt_Change3ActionPerformed(evt);
            }
        });

        jLabel11.setText("Name :");

        javax.swing.GroupLayout pn_PersonInfo3Layout = new javax.swing.GroupLayout(pn_PersonInfo3);
        pn_PersonInfo3.setLayout(pn_PersonInfo3Layout);
        pn_PersonInfo3Layout.setHorizontalGroup(
            pn_PersonInfo3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pn_PersonInfo3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lb_Address3)
                .addGap(18, 18, 18)
                .addGroup(pn_PersonInfo3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txtEmail, javax.swing.GroupLayout.DEFAULT_SIZE, 181, Short.MAX_VALUE)
                    .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 181, Short.MAX_VALUE)
                    .addComponent(txtPhone, javax.swing.GroupLayout.DEFAULT_SIZE, 181, Short.MAX_VALUE)
                    .addComponent(txtName, javax.swing.GroupLayout.DEFAULT_SIZE, 181, Short.MAX_VALUE))
                .addGap(33, 33, 33))
            .addGroup(pn_PersonInfo3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lb_Email3)
                .addContainerGap(247, Short.MAX_VALUE))
            .addGroup(pn_PersonInfo3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(lb_phone3)
                .addContainerGap(241, Short.MAX_VALUE))
            .addGroup(pn_PersonInfo3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel11)
                .addContainerGap(244, Short.MAX_VALUE))
            .addGroup(pn_PersonInfo3Layout.createSequentialGroup()
                .addGap(90, 90, 90)
                .addComponent(bnt_Change3)
                .addContainerGap(103, Short.MAX_VALUE))
        );
        pn_PersonInfo3Layout.setVerticalGroup(
            pn_PersonInfo3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pn_PersonInfo3Layout.createSequentialGroup()
                .addGap(25, 25, 25)
                .addGroup(pn_PersonInfo3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(txtName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(47, 47, 47)
                .addGroup(pn_PersonInfo3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(lb_phone3)
                    .addComponent(txtPhone, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(45, 45, 45)
                .addGroup(pn_PersonInfo3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(txtEmail, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lb_Email3, javax.swing.GroupLayout.Alignment.TRAILING))
                .addGroup(pn_PersonInfo3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pn_PersonInfo3Layout.createSequentialGroup()
                        .addGap(71, 71, 71)
                        .addComponent(lb_Address3))
                    .addGroup(pn_PersonInfo3Layout.createSequentialGroup()
                        .addGap(39, 39, 39)
                        .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(18, 18, 18)
                .addComponent(bnt_Change3)
                .addGap(38, 38, 38))
        );

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(72, 72, 72)
                .addComponent(pn_PersonInfo3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(54, 54, 54)
                .addComponent(pn_MangerInfo1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(59, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(34, 34, 34)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(pn_MangerInfo1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(pn_PersonInfo3, javax.swing.GroupLayout.PREFERRED_SIZE, 400, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(31, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Information", new javax.swing.ImageIcon(getClass().getResource("/Images/Information-icon.png")), jPanel1); // NOI18N

        jPanel7.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Sales Men Report", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 14))); // NOI18N

        jLabel8.setText("Items not Available :");

        jLabel9.setText("Items Sold :");

        bntViewItemNotAvailable.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/1283060576_eye.png"))); // NOI18N
        bntViewItemNotAvailable.setText("View");
        bntViewItemNotAvailable.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bntViewItemNotAvailableActionPerformed(evt);
            }
        });

        bntViewItemSold.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/1283060576_eye.png"))); // NOI18N
        bntViewItemSold.setText("View");
        bntViewItemSold.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bntViewItemSoldActionPerformed(evt);
            }
        });

        jLabel10.setText("Total Money :");

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addGap(152, 152, 152)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel9)
                    .addComponent(jLabel8)
                    .addComponent(jLabel10))
                .addGap(4, 4, 4)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(txtTotalMoney)
                    .addComponent(txtItemSold, javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(txtNotAvailable, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 175, Short.MAX_VALUE))
                .addGap(18, 18, 18)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(bntViewItemNotAvailable)
                    .addComponent(bntViewItemSold))
                .addGap(246, 246, 246))
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addGap(15, 15, 15)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtNotAvailable, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel8)
                    .addComponent(bntViewItemNotAvailable))
                .addGap(23, 23, 23)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(bntViewItemSold)
                    .addComponent(txtItemSold, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel9))
                .addGap(32, 32, 32)
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtTotalMoney, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel10))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel8.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED, java.awt.Color.orange, java.awt.Color.orange, java.awt.Color.orange, java.awt.Color.orange));

        tbItem1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane2.setViewportView(tbItem1);

        javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
        jPanel8.setLayout(jPanel8Layout);
        jPanel8Layout.setHorizontalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 775, Short.MAX_VALUE)
        );
        jPanel8Layout.setVerticalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 227, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jPanel8, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel7, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 781, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(18, 18, 18)
                .addComponent(jPanel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        jTabbedPane1.addTab("Reports", new javax.swing.ImageIcon(getClass().getResource("/Images/distributor-report-icon.png")), jPanel2); // NOI18N

        jLabel5.setText("From  :");

        jLabel6.setText("To now :");

        txtNow.setEditable(false);

        jPanel6.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED, java.awt.Color.orange, java.awt.Color.orange, java.awt.Color.orange, java.awt.Color.orange));

        tbItem2.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        jScrollPane3.setViewportView(tbItem2);

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 775, Short.MAX_VALUE)
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 328, Short.MAX_VALUE)
        );

        cbCate.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-- Type to View --" }));
        cbCate.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbCateActionPerformed(evt);
            }
        });

        jLabel7.setText("View By :");

        cbLastMonth.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-- Choice Month --", "1 Month", "2 Month", "3 Month", "4 Month", "5 Month", "6 Month" }));
        cbLastMonth.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cbLastMonthActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGap(93, 93, 93)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel5)
                    .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 54, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(cbLastMonth, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(cbCate, 0, 111, Short.MAX_VALUE))
                .addGap(106, 106, 106)
                .addComponent(jLabel6)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(txtNow, javax.swing.GroupLayout.PREFERRED_SIZE, 179, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(135, 135, 135))
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGap(74, 74, 74)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(cbCate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel7)))
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGap(24, 24, 24)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(txtNow, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel6)
                            .addComponent(jLabel5)
                            .addComponent(cbLastMonth, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addGap(26, 26, 26)
                .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        jTabbedPane1.addTab("Inventory-Trend", new javax.swing.ImageIcon(getClass().getResource("/Images/Rank-History-icon.png")), jPanel4); // NOI18N

        InventoryStatus.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Inventory Status", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 18))); // NOI18N

        jLabel1.setText("Total Categories :");

        jLabel2.setText("Total Items :");

        jLabel4.setText("Update Item Quantity :");

        txtTotalCate.setEditable(false);

        txtTotalItem.setEditable(false);

        bntUpdate.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Images/Add-icon.png"))); // NOI18N
        bntUpdate.setText("Update");
        bntUpdate.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bntUpdateActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout InventoryStatusLayout = new javax.swing.GroupLayout(InventoryStatus);
        InventoryStatus.setLayout(InventoryStatusLayout);
        InventoryStatusLayout.setHorizontalGroup(
            InventoryStatusLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(InventoryStatusLayout.createSequentialGroup()
                .addGap(59, 59, 59)
                .addGroup(InventoryStatusLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1)
                    .addComponent(jLabel2)
                    .addComponent(jLabel4))
                .addGap(56, 56, 56)
                .addGroup(InventoryStatusLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(InventoryStatusLayout.createSequentialGroup()
                        .addComponent(txtUpdateQuantity, javax.swing.GroupLayout.PREFERRED_SIZE, 190, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(bntUpdate))
                    .addGroup(InventoryStatusLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(txtTotalItem, javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(txtTotalCate, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 191, Short.MAX_VALUE)))
                .addContainerGap(239, Short.MAX_VALUE))
        );
        InventoryStatusLayout.setVerticalGroup(
            InventoryStatusLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(InventoryStatusLayout.createSequentialGroup()
                .addGap(27, 27, 27)
                .addGroup(InventoryStatusLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(txtTotalCate, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(28, 28, 28)
                .addGroup(InventoryStatusLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(txtTotalItem, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(40, 40, 40)
                .addGroup(InventoryStatusLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(txtUpdateQuantity, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(bntUpdate))
                .addContainerGap(33, Short.MAX_VALUE))
        );

        jPanel5.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED, new java.awt.Color(102, 255, 255), new java.awt.Color(102, 255, 255), new java.awt.Color(102, 255, 255), new java.awt.Color(102, 255, 255)));

        tbItem.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Title 1", "Title 2", "Title 3", "Title 4"
            }
        ));
        tbItem.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                tbItemMouseClicked(evt);
            }
        });
        jScrollPane1.setViewportView(tbItem);

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 757, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 163, Short.MAX_VALUE)
                .addContainerGap())
        );

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jPanel5, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(InventoryStatus, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(InventoryStatus, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );

        jTabbedPane1.addTab("Inventory Status", new javax.swing.ImageIcon(getClass().getResource("/Images/packing-icon.png")), jPanel3); // NOI18N

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jTabbedPane1)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 511, Short.MAX_VALUE)
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    public void getTotalCate()
    {
        int totalCate = new InventoryManagementFunction_BL().getTotalCate_BL();
        txtTotalCate.setText(String.valueOf(totalCate));
    }
    public void getTotalItems()
    {
        int totalItems  = new InventoryManagementFunction_BL().getTotalItems_BL();
        txtTotalItem.setText(String.valueOf(totalItems));
    }
    private void bntViewItemNotAvailableActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bntViewItemNotAvailableActionPerformed
        // TODO add your handling code here:
        if (ItemNot==0) {
            JOptionPane.showMessageDialog(this, "No Item not Available to View !", "Error !", 2, null);
        } else {
            TableModel tb=function_BL.GetItemNotAvailable();
            tbItem1.setModel(tb);
        }
    }//GEN-LAST:event_bntViewItemNotAvailableActionPerformed

    public void GenerateInfo()
    {
        ItemNot=function_BL.ViewItemNotAvailable();
        String ViewItemNotAvailable=String.valueOf(ItemNot);
        txtNotAvailable.setText(ViewItemNotAvailable);

        Total=function_BL.getTotalPrice();
        String TotalPrice=String.valueOf(Total);
        txtTotalMoney.setText(TotalPrice+"$");

        int TotalItemSold=function_BL.getTotalItemSold();
        String itemSold=String.valueOf(TotalItemSold);
        txtItemSold.setText(itemSold);
        getDate();
        //getCategory();
        getTotalCate();
        getTotalItems();
        ItemList();
    }
    private void bntViewItemSoldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bntViewItemSoldActionPerformed
        // TODO add your handling code here:

        if (Total==0) {
            JOptionPane.showMessageDialog(this, "No Items sold to View !", "Error !", 2, null);
        } else {

            TableModel tb=function_BL.getItemsSold();
            tbItem1.setModel(tb);
        }
    }//GEN-LAST:event_bntViewItemSoldActionPerformed

    private void bntUpdateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bntUpdateActionPerformed
        // TODO add your handling code here:
        String temp = txtUpdateQuantity.getText();
        if (temp.equals("")) {
            JOptionPane.showMessageDialog(this, "Enter Item Quantity!", "Error !", 2, null);
        } else {
            int quantity = Integer.parseInt(temp);
            if (quantity <= 0) {
                JOptionPane.showMessageDialog(this, "Invalid Quantity!", "Error !", 2, null);
            } else {
                int TotalItem=(Integer.parseInt(Quantity))+quantity;
                String message = new InventoryManagementFunction_BL().updateQuantity(TotalItem,ItemID);
                JOptionPane.showMessageDialog(this, message);
                ItemList();
                txtUpdateQuantity.setText("");
            }
        }
    }//GEN-LAST:event_bntUpdateActionPerformed

    private void bntChangePass1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bntChangePass1ActionPerformed
        // TODO add your handling code here:
        new ChangePass(user).setVisible(true);
    }//GEN-LAST:event_bntChangePass1ActionPerformed

    private void bnt_Change3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bnt_Change3ActionPerformed
        // TODO add your handling code here:
        if(ValidateInfoForm()==1) {
            String message = new AdminFunction().updateInfor_BL(user.getUserID(),txtName.getText(),txtPhone.getText(),txtEmail.getText(),txtAddress.getText());
            JOptionPane.showMessageDialog(this, message);
        }
    }//GEN-LAST:event_bnt_Change3ActionPerformed

    public void getDate()
    {
        String dateFormat="MM/dd/yyyy";
        Calendar cal = Calendar.getInstance();
        SimpleDateFormat sd = new SimpleDateFormat(dateFormat);
        String dateNow = (String)sd.format(cal.getTime());
        txtNow.setText(dateNow);
    }
    private void tbItemMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tbItemMouseClicked
        // TODO add your handling code here:
        int counts = tbItem.getSelectedRow();
        ItemID = (String)tbItem.getValueAt(counts, 0);
        Quantity = (String) tbItem.getValueAt(counts, 4);
        txtUpdateQuantity.setText(Quantity);
        
    }//GEN-LAST:event_tbItemMouseClicked

    private void cbLastMonthActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbLastMonthActionPerformed
        // TODO add your handling code here:
        Index=cbLastMonth.getSelectedIndex();
        if(Index != 0)
        {
            for(int i=1;i<cbCate.getItemCount();i++)
            {
                cbCate.removeItemAt(i);
            }

            getCategory(Index);
        }
    }//GEN-LAST:event_cbLastMonthActionPerformed

    private void cbCateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbCateActionPerformed
        // TODO add your handling code here:
        int CateIndex=cbCate.getSelectedIndex();
        String Cate=cbCate.getSelectedItem().toString();
        if(CateIndex!=0)
        {
            getItembyCategory(Cate,Index);
        }
    }//GEN-LAST:event_cbCateActionPerformed
    public void ItemList()
    {
       TableModel tbm=new InventoryManagementFunction_BL().ItemTable();
        tbItem.setModel(tbm);
    }
    public int ValidateInfoForm() {
        InfoName = txtName.getText();
        InfoPhone = txtPhone.getText();
        InfoEmail = txtEmail.getText();
        InfoAddress = txtAddress.getText();
        InfoUserName = txtUserName.getText();
        InfoRoles = txtRoles.getText();
        String per = txtPer.getText();
        if (InfoName.equals("")) {
            JOptionPane.showMessageDialog(this, "Enter Your Name !", "Error !", 2, null);
            txtName.requestFocus();
            return 0;
        } else if (InfoPhone.equals("")) {
            JOptionPane.showMessageDialog(this, "Enter Your Phone Number !", "Error !", 2, null);
            txtPhone.requestFocus();
            return 0;
        } else if (InfoEmail.equals("")) {
            JOptionPane.showMessageDialog(this, "Enter Your Contac Email !", "Error !", 2, null);
            txtEmail.requestFocus();
            return 0;
        } else if (InfoAddress.equals("")) {
            JOptionPane.showMessageDialog(this, "Enter Your Address !", "Error !", 2, null);
            txtAddress.requestFocus();
            return 0;
        }
        return 1;
    }

    public void getCategory(int Index)
    {
        Vector Cate=function_BL.GetCategory(Index);
        for(Object o : Cate)
        {
            cbCate.addItem(o);
        }
    }

    public void getItembyCategory(String CateName,int Index)
    {
        TableModel tbModel=function_BL.getItembyCate(CateName,Index);
        tbItem2.setModel(tbModel);
    }

    //variable for Information form
    private String ItemID;
    private String InfoName;
    private String InfoPhone;
    private String InfoEmail;
    private String InfoAddress;
    private String InfoUserName;
    private String InfoRoles;
    private int InfoPermission;
    private int ItemNot;
    private float Total;
    private String Quantity;
    private int Index;
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel InventoryStatus;
    private javax.swing.JButton bntChangePass1;
    private javax.swing.JButton bntUpdate;
    private javax.swing.JButton bntViewItemNotAvailable;
    private javax.swing.JButton bntViewItemSold;
    private javax.swing.JButton bnt_Change3;
    private javax.swing.JComboBox cbCate;
    private javax.swing.JComboBox cbLastMonth;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JLabel lb_Address3;
    private javax.swing.JLabel lb_Email3;
    private javax.swing.JLabel lb_Roles1;
    private javax.swing.JLabel lb_permis1;
    private javax.swing.JLabel lb_phone3;
    private javax.swing.JLabel lb_username1;
    private javax.swing.JPanel pn_MangerInfo1;
    private javax.swing.JPanel pn_PersonInfo3;
    private javax.swing.JTable tbItem;
    private javax.swing.JTable tbItem1;
    private javax.swing.JTable tbItem2;
    private javax.swing.JTextArea txtAddress;
    private javax.swing.JTextField txtEmail;
    private javax.swing.JTextField txtItemSold;
    private javax.swing.JTextField txtName;
    private javax.swing.JTextField txtNotAvailable;
    private javax.swing.JTextField txtNow;
    private javax.swing.JTextField txtPer;
    private javax.swing.JTextField txtPhone;
    private javax.swing.JTextField txtRoles;
    private javax.swing.JTextField txtTotalCate;
    private javax.swing.JTextField txtTotalItem;
    private javax.swing.JTextField txtTotalMoney;
    private javax.swing.JTextField txtUpdateQuantity;
    private javax.swing.JTextField txtUserName;
    // End of variables declaration//GEN-END:variables
}
